

// 取字典列表
interface DictionaryItem {
    id: string;
    title: string;
    icon_url: string;
    type: string;
    code: number;
    color: string;
    created_at: string;
    updated_at: string;
    added_by: string;
}
/**
 * 取字典列表
 * data store dictionary 列表
 * type 字典类型
 * **/
// 
export const formatDictionaryList = (data: [], type: string) => {
    const arr = [];
    data.forEach((item: DictionaryItem) => {
        if (item.type === type) {
            arr.push(item);
        }
    });
    return arr;
};
/**
 * 已取出的字典列表
 * code 字典code
 * **/
// 
import useCommonStore from '@/stores/common.js'
const { dictionary } = useCommonStore()
export const formatDictionaryItem = (type: string, code: number) => {
    let name = ''
    dictionary.forEach((item: DictionaryItem) => {
        if (item.type == type) {
            if (item.code == code) {
                name = item.title
            }
        }
    })
    return name
};
